package com.seguriapp.gwt.client.login;

import com.google.gwt.event.shared.GwtEvent;
import com.seguriapp.entities.Alert;

public class AlertReceivedEvent extends GwtEvent<AlertReceivedEventHandler> {

  public static final Type<AlertReceivedEventHandler> TYPE = new Type<AlertReceivedEventHandler>();

  private final Long alertId;
  private final Alert alert;
  private final int alertsCount;

  public AlertReceivedEvent(final Long alertId, final Alert alert, final int alertsCount) {
    this.alertId = alertId;
    this.alert = alert;
    this.alertsCount = alertsCount;
  }

  @Override
  public GwtEvent.Type<AlertReceivedEventHandler> getAssociatedType() {
    return TYPE;
  }

  @Override
  protected void dispatch(AlertReceivedEventHandler handler) {
    handler.onNewAlert(this);
  }

  public static Type<AlertReceivedEventHandler> getType() {
    return TYPE;
  }

  public Long getAlertId() {
    return alertId;
  }

  public Alert getAlert() {
    return alert;
  }

  public int getAlertsCount() {
    return alertsCount;
  }

}
